﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using AntC.AspNetCore.ApiEncryption.Internal.Interfaces;
using AntC.AspNetCore.ApiEncryption.Internal.Streams;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace AntC.AspNetCore.ApiEncryption.Internal
{
    /// <summary>
    /// api encryption context
    /// </summary>
    public class ApiEncryptionContext
    {
        internal ApiEncryptionContext(HttpContext httpContext,
            ILogger logger,
            IEncryptProvider encryptProvider,
            IApiEncryptionPolicyProvider policyProvider,
            IOptionsSnapshot<ApiEncryptionOptions> options)
        {
            HttpContext = httpContext;
            Logger = logger;
            EncryptProvider = encryptProvider;
            PolicyProvider = policyProvider;
            ApiEncryptionOptions = options.Value;
        }

        /// <summary>
        /// http context
        /// </summary>
        public HttpContext HttpContext { get; }

        /// <summary>
        /// api encryption policy provider
        /// </summary>
        public IApiEncryptionPolicyProvider PolicyProvider { get; }

        /// <summary>
        /// encrypt provider
        /// </summary>
        public IEncryptProvider EncryptProvider { get; }

        internal ApiEncryptionOptions ApiEncryptionOptions { get; }

        internal ILogger Logger { get; }

        internal Stream OriginalRequestStream { get; set; }

        internal Stream OriginalResponseStream { get; set; }

        internal ApiEncryptStream ApiEncryptRequestStream { get; set; }

        internal ApiEncryptStream ApiEncryptResponseStream { get; set; }

        internal string ResponseContentType { get; set; }
    }
}
